@use './variables' as *;
@use './global' as *;

:root {
  --navbar-height: 64px;
  --navbar-height-mobile: 56px;
}

.navbar {
  color:  var(--md-sys-color-on-primary);
  @extend .z-depth-1;
  background-color: var(--md-sys-color-secondary-container);
  width: 100%;
  height: var(--navbar-height-mobile);
  line-height: var(--navbar-height-mobile);

  &.nav-extended {
    height: auto;

    .nav-wrapper {
      min-height: var(--navbar-height-mobile);
      height: auto;
    }
    
    .nav-content {
      position: relative;
      line-height: normal;
    }
  }

  a {
    color:  var(--md-sys-color-on-primary);
  }

  i,
  [class^="mdi-"], [class*="mdi-"],
  i.material-icons, i.material-symbols-outlined,
  i.material-symbols-rounded, i.material-symbols-sharp {
    display: block;
    font-size: 24px;
    height: var(--navbar-height-mobile);
    line-height: var(--navbar-height-mobile);
  }

  .nav-wrapper {
    position: relative;
    height: 100%;
  }

  @media #{$large-and-up} {
    a.sidenav-trigger {
      display: none;
    }
  }

  // Collapse button
  .sidenav-trigger {
    float: left;
    position: relative;
    z-index: 1;
    height: var(--navbar-height-mobile);
    margin: 0 18px;

    i {
      height: var(--navbar-height-mobile);
      line-height: var(--navbar-height-mobile);
    }
  }

  // Logo
  .brand-logo {
    position: absolute;
    color:  var(--md-sys-color-on-primary);
    display: inline-block;
    font-size: 2.1rem;
    padding: 0;

    &.center {
      left: 50%;
      transform: translateX(-50%);
    }

    @media #{$medium-and-down} {
      left: 50%;
      transform: translateX(-50%);

      &.left, &.right {
        padding: 0;
        transform: none;
      }

      &.left {
        left: 0.5rem;
      }
      &.right {
        right: 0.5rem;
        left: auto;
      }
    }

    &.right {
      right: 0.5rem;
      padding: 0;
    }

    i,
    [class^="mdi-"], [class*="mdi-"],
    i.material-icons, i.material-symbols-outlined,
    i.material-symbols-rounded, i.material-symbols-sharp {
      float: left;
      margin-right: 15px;
    }
  }


  // Title
  .nav-title {
    display: inline-block;
    font-size: 32px;
    padding: 28px 0;
  }


  // Navbar Links
  ul:not(.dropdown-content) {
    list-style-type: none;
    margin: 0;

    & > li {
      transition: background-color .3s;
      float: left;
      padding: 0;

      & > a {
        transition: background-color .3s;
        font-size: 1rem;
        color:  var(--md-sys-color-on-primary);
        display: block;
        padding: 0 15px;
        cursor: pointer;

        &.active {
          background-color: var(--md-sys-color-primary-container-dark);
        }

        &:hover:not(.active) {
          background-color: var(--md-sys-color-on-primary-dark);
        }

        &.btn, &.btn-large, &.btn-flat, &.btn-floating {
          margin-top: -2px;
          margin-left: 15px;
          margin-right: 15px;
          display: inline-block;

          & > .material-icons, & > .material-symbols-outlined,
          & > .material-symbols-rounded, & > .material-symbols-sharp {
            height: inherit;
            line-height: inherit;
          }
        }
      }
    }

    &.left {
      float: left;
    }
  }

  // Navbar Search Form
  form {
    height: 100%;
  }

  .input-field {
    margin: 0;
    height: 100%;

    input[type=search] {
      height: 100%;
      font-size: 1.2rem;
      border: none;
      padding-left: 2rem;
      color:  var(--md-sys-color-on-primary);

      &:focus, &[type=text]:valid, &[type=password]:valid,
      &[type=email]:valid, &[type=url]:valid, &[type=date]:valid {
        border: none;
        box-shadow: none;
      }
    }

    label {
      top: 0;
      left: 0;

      i {
        color: var(--font-on-primary-color-medium);
        transition: color .3s;
      }

      &.active i {
        color:  var(--md-sys-color-on-primary)
      }
    }
  }
}

// Fixed Navbar
.navbar-fixed {
  position: relative;
  height: var(--navbar-height-mobile);
  z-index: 997;

  .navbar {
    position: fixed;
    right: 0;
  }
}

@media #{$medium-and-up} {
  .nav.nav-extended .nav-wrapper {
    min-height: var(--navbar-height-mobile);
  }
  .nav, .navbar .nav-wrapper i, nav a.sidenav-trigger, .navbar a.sidenav-trigger i {
    height: var(--navbar-height);
    line-height: var(--navbar-height)
  }
  .navbar-fixed {
    height: var(--navbar-height);
  }
}
